package com.jackeysun.widget.media

import android.util.Log

/**
 *   Created by sunxunchao on 2021/12/29.
 */
object SinglePlayer {

    private val TAG = SinglePlayer::class.java.simpleName

    lateinit var mSimplePlayer: SimplePlayer

    fun build(): SimplePlayer {
        mSimplePlayer = SimplePlayer()
        return mSimplePlayer
    }

    fun setStatusListener(onPlayerStatusChangeListener: SimplePlayer.OnPlayerStatusChangeListener): SinglePlayer {
        mSimplePlayer.onPlayerStatusChangeListener = onPlayerStatusChangeListener
        return this
    }

    fun reset(): SinglePlayer {
        mSimplePlayer.reset()
        return this
    }

    fun setSource(path: String): SinglePlayer {
        mSimplePlayer.setSource(path)
        return this
    }

    fun start(): SinglePlayer {
        mSimplePlayer.start()
        return this
    }

    fun pause(): SinglePlayer {
        mSimplePlayer.pause()
        return this
    }

    fun stop(): SinglePlayer {
        mSimplePlayer.stop()
        return this
    }

    fun release(): SinglePlayer {
        mSimplePlayer.release()
        return this
    }

    fun seekTo(msec: Int): SinglePlayer {
        mSimplePlayer.seekTo(msec)
        return this
    }

    fun setSpeed(speed: Float): SinglePlayer {
        val speed2 = mSimplePlayer.setSpeed(speed)
        Log.d(TAG, "setSpeed: $speed2")
        return this
    }

}